package com.xw.hchat.service.impl;

import com.xw.hchat.mapper.TbChatRecordMapper;
import com.xw.hchat.pojo.TbChatRecord;
import com.xw.hchat.service.ChatRecordService;
import com.xw.hchat.util.IdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @ClassName ChatRecordServiceImpl
 * @Author liu zhiyong
 * @Date 2020/8/19 15:54
 * @Version 1.0
 */
@Service
@Transactional
public class ChatRecordServiceImpl implements ChatRecordService {

    @Resource
    private TbChatRecordMapper chatRecordMapper;
    @Autowired
    private IdWorker idWorker;

    @Override
    public void insert(TbChatRecord chatRecord) {

        chatRecord.setId(idWorker.nextId());
        chatRecord.setHasRead(0);//默认未读
        chatRecord.setCreatetime(new Date());
        chatRecord.setHasDelete(0);//默认删除

        chatRecordMapper.insert(chatRecord);
    }
}
